package net.zxjava.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

import net.zxjava.gateway.filters.AccessHeaderFilter;
import net.zxjava.gateway.filters.PermissionFilter;
import net.zxjava.gateway.filters.PreRouteFilter;

@PropertySource("classpath:spring.properties")
@EnableZuulProxy
@SpringCloudApplication
@EnableEurekaClient
@EnableFeignClients(basePackages = "net.zxjava.gateway")
public class GatewayApplication {

	public static void main(String[] args) {
		SpringApplication application = new SpringApplication(GatewayApplication.class);
		application.run();
	}

	@Bean
	public AccessHeaderFilter AccessHeaderFilter() {
		return new AccessHeaderFilter();
	}

	/*
	 * @Bean public ErrorFilter ErrorFilter() { return new ErrorFilter(); }
	 */
	@Bean
	public PermissionFilter PermissionFilter() {
		return new PermissionFilter();
	}

	@Bean
	public PreRouteFilter routeFilter() {
		return new PreRouteFilter();
	}
}
